﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPFTaskbarNotifier;
using System.Collections.ObjectModel;

namespace OSVDB_TrayApp
{

    public class NotifyObject
    {
        public NotifyObject(string message, string title)
        {
            this.message = message;
            this.title = title;
        }

        private string title;
        public string Title
        {
            get { return this.title; }
            set { this.title = value; }
        }

        private string message;
        public string Message
        {
            get { return this.message; }
            set { this.message = value; }
        }
    }

    /// <summary>
    /// Interaction logic for NotifyBox.xaml
    /// </summary>
    public partial class NotifyBox : TaskbarNotifier
    {
        public NotifyBox()
        {
            InitializeComponent();
        }

        Window1 owner;

        public NotifyBox(Window1 _owner)
        {
            owner = _owner;
            InitializeComponent();
        }

         private ObservableCollection<NotifyObject> notifyContent;
        /// <summary>
        /// A collection of NotifyObjects that the main window can add to.
        /// </summary>
        public ObservableCollection<NotifyObject> NotifyContent
        {
            get
            {
                if (this.notifyContent == null)
                {
                    // Not yet created.
                    // Create it.
                    this.NotifyContent = new ObservableCollection<NotifyObject>();
                }

                return this.notifyContent;
            }
            set
            {
                this.notifyContent = value;
            }
        }

        private void Item_Click(object sender, EventArgs e)
        {
            Hyperlink hyperlink = sender as Hyperlink;

            if(hyperlink == null)
                return;

            NotifyObject notifyObject = hyperlink.Tag as NotifyObject;
            if(notifyObject != null)
            {
                switch (notifyObject.Title)
	            {
                    case "Information":
                        Setting set = new Setting();
                        set.Show();
                        break;
                    case "OSVDB":
                        this.owner.Show();
                        this.owner.tab_OSVDB.Focus();
                        break;
                    case "Milw0rm":
                        this.owner.Show();
                        this.owner.tab_Milworm.Focus();
                        break;
                    case "Security Focus":
                        this.owner.Show();
                        this.owner.tab_SecFoc.Focus();
                        break;
                    case "Packet Storm Advisories":
                        this.owner.Show();
                        this.owner.tab_PacketStormADV.Focus();
                        break;
                    case "Packet Storm Exploits":
                        this.owner.Show();
                        this.owner.tab_PacketStormEXP.Focus();
                        break;
		            default:
                        break;
	            }
            }
        }

        private void HideButton_Click(object sender, EventArgs e)
        {
            this.ForceHidden();
        }
    }
}

